// 命令式统计行数

#include <iostream>
#include <fstream>
#include <vector>
using namespace std;

vector<int> count_lines_in_files(vector<string>& files) {
    vector<int> results;

    char c = 0;
    for (const auto& file : files) {
        int line_count = 0;

        ifstream in(file);
        while (in.get(c)) {
            if (c == '\n') {
                line_count++;
            }
        }

        results.push_back(line_count);
    }

    return results;
}

int main() {
    vector<string> files{"ch01/1_1.cpp"};
    for (int line_count : count_lines_in_files(files)) {
        cout << line_count << "\n";
    }
}
